package com.situ.mall.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.situ.mall.common.ServerResponse;
import com.situ.mall.dao.CategoryMapper;
import com.situ.mall.entity.Category;
import com.situ.mall.entity.CategoryCount;
import com.situ.mall.service.ICategoryService;

@Service
public class CategoryServiceImpl implements ICategoryService{

	@Autowired
	private CategoryMapper categoryMapper;
	
	@Override
	public ServerResponse getProductSelect() {
		List<Category> data = categoryMapper.getProductSelect();
		if (null == data) {
			return ServerResponse.createError("获取失败");
		}
		return ServerResponse.createSuccess("获取成功", data);
	}

	@Override
	public ServerResponse getTopCategorySelect() {
		List<Category> data = categoryMapper.getTopCategorySelect();
		if (null == data) {
			return ServerResponse.createError("获取失败");
		}
		return ServerResponse.createSuccess("获取成功", data);
	}

	@Override
	public ServerResponse getSecondCategorySelect(Integer secondCategoryId) {
		List<Category> data = categoryMapper.getSecondCategorySelect(secondCategoryId);
		if (null == data) {
			return ServerResponse.createError("获取失败");
		}
		return ServerResponse.createSuccess("获取成功", data);
	}

	@Override
	public ServerResponse getUpdateSecondCategorySelect(Integer id) {
		List<Category> data = categoryMapper.getUpdateSecondCategorySelect(id);
		if (null == data) {
			return ServerResponse.createError("获取失败");
		}
		return ServerResponse.createSuccess("获取成功", data);
	}

	@Override
	public List<Category> selectTopCategoryList() {
		List<Category> list = categoryMapper.getTopCategorySelect();
		return list;
	}

	@Override
	public List<Category> selectSecondCategoryList() {
		List<Category> list = categoryMapper.selectSecondCategoryList();
		return list;
	}

	@Override
	public ServerResponse getCategoryCount() {
		List<CategoryCount> list = categoryMapper.getCategoryCount();
		return ServerResponse.createSuccess("查询成功", list);
	}

}
